<?php

declare(strict_types=1);

namespace app\common\service\crm;

use app\common\service\sys\DictService;
use app\common\traits\ServiceTrait;
use app\common\dao\crm\ClueDao;

/**
 * 客户线索表 服务业务层(Service)
 * @author 吕玉冰
 * @date  2022-07-19
 * @copyright ©2022 泉州市盛筑信息科技有限公司 版权所有
 */
class ClueService
{
    protected $dao = null;

    public function __construct()
    {
        $this->dao = new ClueDao();
        $this->dictDao = new DictService();
    }

    use ServiceTrait;

    public function _list_format($data)
    {

//        foreach ($data as $key => $value) {
//            $data[$key]['source_name'] = $source_list[$value['source']];
//        }

        return $data;
    }

    /**
     * lvyubing
     * @param $data
     */
    public function _out_form_filter(&$data)
    {
        $where = [];
        $where[] = ["code", "=", "clue_source"];
        $info = $this->dictDao->getInfoByWhere($where);
        $where = [];
        $where[] = ["pid", "=", $info['id']];
        $list = $this->dictDao->getListAll($where);
        $temp = [];
        foreach ($list as $key => $value) {
            $temp[$value['value']] = $value['name'];
        }
        $data['source_name'] = $temp[$data['source']];


        $where = [];
        $where[] = ["code", "=", "clue_level"];
        $info = $this->dictDao->getInfoByWhere($where);
        $where = [];
        $where[] = ["pid", "=", $info['id']];
        $list = $this->dictDao->getListAll($where);
        $temp = [];
        foreach ($list as $key => $value) {
            $temp[$value['value']] = $value['name'];
        }
        $data['level_name'] = $temp[$data['level']];

        $where = [];
        $where[] = ["code", "=", "clue_industry"];
        $info = $this->dictDao->getInfoByWhere($where);
        $where = [];
        $where[] = ["pid", "=", $info['id']];
        $list = $this->dictDao->getListAll($where);
        $temp = [];
        foreach ($list as $key => $value) {
            $temp[$value['value']] = $value['name'];
        }
        $data['industry_name'] = $temp[$data['industry']];

    }


}
    